Repository navigation
fix(ai-analyzer): drop stale fingerprint matches when finding Slack thread parent - #88
Merged
Merged
Conversation
…hread parent
같은 알람이 시간 간격을 두고 재발화할 때 ai-analyzer 가 옛 부모
thread 에 reply 박는 현상 발견. 본 채널 history 진단에서 같은
fingerprint 의 옛 부모 (12h 전) 에 reply 가 누적되고, 새 부모는
replies=0 으로 빈 채로 남아 있음.
원인: `_find_thread_ts` 가 채널 history 에서 fingerprint marker 가
박힌 첫 메시지를 그대로 반환. Slack history 가 newest-first 정렬이지만
- (a) `SLACK_HISTORY_LOOKBACK=30` 이 ai-analyzer 자기 standalone post 로
잠식되어 새 부모가 slot 밖으로 밀려나기도 하고
- (b) 같은 fingerprint 의 옛 부모가 호출 시점에 history 안에 살아 있으면
그게 매치되기 때문.
Fix:
- `_find_thread_ts` 가 매칭 후보를 모두 수집한 후 `SLACK_PARENT_MAX_AGE_MIN`
(기본 30분) 이내만 남기고 그 중 ts 가장 큰 것을 선택. first-match
bias 도 제거.
- `SLACK_HISTORY_LOOKBACK` 기본값 30 → 100 (chart values).
- `SLACK_PARENT_MAX_AGE_MIN` env 신규.
- README env 표 동기화.
검증 시점에 옛 부모 reply 가 standalone fallback 으로도 history 잠식되지
는 않음 (fallback 메시지에는 fingerprint marker 박지 않으므로) — 즉 이번
변경은 marker-bearing 부모만 영향.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
같은 알람이 시간 간격을 두고 재발화할 때 ai-analyzer 가 옛 부모 thread 에 reply 박는 현상 fix.
Why
본 채널 (
#alerts/C0B7SHREBAB) history 진단 결과:같은 fingerprint 의 옛 부모에는 reply 가 쌓이고, 방금 firing 한 새 부모에는 reply 0. ai-analyzer 가 같은 fingerprint 의 옛 부모를 thread parent 로 잘못 잡고 있음.
원인:
_find_thread_ts가 채널 history 의 fingerprint marker 첫 매치를 그대로 반환.SLACK_HISTORY_LOOKBACK=30이 ai-analyzer 자기 standalone fallback post 로 잠식되어 새 부모가 slot 밖으로 밀려나거나 ② 같은 fingerprint 의 옛 부모가 호출 시점에 history 안에 살아 있으면 그게 첫 매치가 됨.What
apps/ai/ai-analyzer/app/slack.py의_find_thread_ts강화:SLACK_PARENT_MAX_AGE_MIN(기본 30분) 이내 후보만 채택. 12시간 묵은 옛 부모는 자동 skip.ts내림차순 정렬해 가장 최신 채택.SLACK_HISTORY_LOOKBACK100 으로 증가 — 새 부모가 history 30 밖으로 밀려나는 케이스 차단.chart/values.yaml+README.mdenv 표 동기화.Files
Validation
머지 후 CI bump → ArgoCD sync 까지 ~3분. 다음 firing 부터:
검증 스크립트로 같은 채널 history 에 새 부모 게시 후 ai-analyzer 가 그 thread 에 박는지 conversations.replies 로 확인.
Notes
SLACK_PARENT_MAX_AGE_MIN=30은 Alertmanager 의group_interval=5m+ 적당한 retry 마진. 환경에 따라 env 로 조정 가능.AGENT_ENABLED=false와 무관하게 single-shot 경로에서도 동일 효과.🤖 Generated with Claude Code